package com.sid.oncf.dao.impl;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.springframework.transaction.annotation.Transactional;

import com.sid.oncf.dao.interfaces.IGareDao;
import com.sid.oncf.entity.Gares;


public class GareDaoImpl implements IGareDao {

	@PersistenceContext
	private EntityManager em;
	
	public boolean save(Gares g) {
		em.persist(g);
		return true;
	}

	public boolean update(Gares g) {
		em.merge(g);
		return true;
	}

	public boolean delete(int id) {
		em.remove(find(id));
		return true;
	}

	public Gares find(int id) {
		return em.find(Gares.class, id);
	}

	public List<Gares> findAll() {
		Query query=em.createQuery("select g from Gares g",Gares.class);
		return query.getResultList();
	}

}
